home *** CD-ROM | disk | FTP | other *** search
- @echo off
- ! cp.bat Batch file to copy a folder or a file to a folder
- !
- ! cp name [dest]
- !
- ! where 'name' is the item to be copied and 'dest' is the folder which
- ! shall contain a copy of 'name'. Both names can be preceded by paths and
- ! volume IDs.
- ! If 'dest' is missing, the current directory is used as destination.
- !
- ! cp.bat calls copydir
- !
- ! Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
- !
-
- ! ensure that the first parameter is there and that the third one is not
- set doserr=13
- if not "%3 " == " " goto ERR_LBL
- if "%1 " == " " goto ERR_LBL
-
- ! determine the destination (ensuring that it is a folder)
- set cp_folder=%WHERE%
- if "%2 " == " " goto FOLDER_OK_LBL
- if not existdir "%2" goto ERR_LBL
- set cp_folder=%2
- :FOLDER_OK_LBL
-
- ! do the copying
- onerror ERR_LBL
- if not existdir "%1" goto COPY_FILE_LBL
- copydir "%1" "%cp_folder%"
- goto DONE_LBL
- :COPY_FILE_LBL
- copy "%1" "%cp_folder%"
- goto DONE_LBL
-
- :ERR_LBL
- show %doserr%
-
- :DONE_LBL
- ! remove the global variables
- set cp_name=
- set cp_folder=
-